Saetl.net

Simple And Easy TempLate

jssor sliderの使い方

  1. 下記ページの 「Download Source Code + Development Kit」 よりファイル1式をダウンロード。
  2. ダウンロードしたファイルを任意の場所にコピー。
    ファイル構成

    ※以下は full-width-slider のコード解説

  3. 動作させるファイル(サンプルではfull-width-slider.html)にコードを記述。
    パスは上記ファイル構成の場合なので環境にあわせて変更>
    ・head部分にcssファイルを読み込ませるためのコードを記述。
    <head>
    <!--cssを外部化したファイル-->
    <link rel="stylesheet" href="css/full-width-slider.css">
    </head>
    

    サンプルのcssコード(サンプルのcssは改変しています)

    /*ページ設定部分(style.cssなどで設定していれば削除する)*/
    body {
    	margin: 0;
    	padding: 0;
    	background: #fff;
    }
    /*ここまでページ設定部分*/
    
    
    /*ここからjssor sliderの設定*/
    
    /* full-width-slider */
    .jssorb21 {
    	position: absolute;
    }
    .jssorb21 div, .jssorb21 div:hover, .jssorb21 .av {
    	position: absolute;
    	/* size of bullet elment */
    	width: 19px;
    	height: 19px;
    	text-align: center;
    	line-height: 19px;
    	color: white;
    	font-size: 12px;
    	background: url(../images/full-width-slider/b21.png) no-repeat;
    	overflow: hidden;
    	cursor: pointer;
    }
    .jssorb21 div {
    	background-position: -5px -5px;
    }
    .jssorb21 div:hover, .jssorb21 .av:hover {
    	background-position: -35px -5px;
    }
    .jssorb21 .av {
    	background-position: -65px -5px;
    }
    .jssorb21 .dn, .jssorb21 .dn:hover {
    	background-position: -95px -5px;
    }
    .jssora21l, .jssora21r {
    	display: block;
    	position: absolute;
    	/* size of arrow element */
    	width: 55px;
    	height: 55px;
    	cursor: pointer;
    	background: url(../images/full-width-slider/a21.png) center center no-repeat;
    	overflow: hidden;
    }
    .jssora21l {
    	background-position: -3px -33px;
    }
    .jssora21r {
    	background-position: -63px -33px;
    }
    .jssora21l:hover {
    	background-position: -123px -33px;
    }
    .jssora21r:hover {
    	background-position: -183px -33px;
    }
    .jssora21l.jssora21ldn {
    	background-position: -243px -33px;
    }
    .jssora21r.jssora21rdn {
    	background-position: -303px -33px;
    }
    
    ・</body>の直前にjsファイルを読み込ませるためのコードを記述。
    <!--googleのCDN(ネットワーク経由でコンテンツを提供するサービス)よりjqueryをロード-->
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <!--ダウンロードしたファイル-->
    <script type="text/javascript" src="js/jssor.js"></script>
    <script type="text/javascript" src="js/jssor.slider.min.js"></script>
    <!--jsを外部化したファイル-->
    <script type="text/javascript" src="js/full-width-slider.js"></script>
    
    
    ・<body></body>内にコードを記述。
    <div id="slider1_container" style="position: relative; margin: 0 auto;
            top: 0px; left: 0px; width: 1300px; height: 500px; overflow: hidden;">
    
        <!-- Slides Container -->
        <div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 1300px;height: 500px; overflow: hidden;">
          <div> <img u="image" src="images/full-width-slider/red.jpg" />
            <div u="caption" t="NO" t3="RTT|2" r3="137.5%" du3="3000" d3="500" style="position: absolute; width: 445px; height: 300px; top: 100px; left: 600px;"> <img src="images/full-width-slider/c-phone.png" style="position: absolute; width: 445px; height: 300px; top: 0px; left: 0px;" /> <img u="caption" t="CLIP|LR" du="4000" t2="NO" src="images/full-width-slider/c-jssor-slider.png" style="position: absolute; width: 102px; height: 78px; top: 70px; left: 130px;" /> <img u="caption" t="ZMF|10" t2="NO" src="images/full-width-slider/c-text.png" style="position: absolute; width: 80px; height: 53px; top: 153px; left: 163px;" /> <img u="caption" t="RTT|10" t2="NO" src="images/full-width-slider/c-fruit.png" style="position: absolute; width: 140px; height: 90px; top: 60px; left: 220px;" /> <img u="caption" t="T" du="4000" t2="NO" src="images/full-width-slider/c-navigator.png" style="position: absolute; width: 200px; height: 155px; top: 57px; left: 121px;" /> </div>
            <div u="caption" t="RTT|2" r="-75%" du="1600" d="2500" t2="NO" style="position: absolute; width: 470px; height: 220px; top: 120px; left: 650px;"> <img src="images/full-width-slider/c-phone-horizontal.png" style="position: absolute; width: 470px; height: 220px; top: 0px; left: 0px;" /> <img u="caption" t3="MCLIP|L" du3="2000" src="images/full-width-slider/c-slide-1.jpg" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" /> <img u="caption" t="MCLIP|R" du="2000" t2="NO" src="images/full-width-slider/c-slide-3.jpg" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" /> <img u="caption" t="RTTL|BR" x="500%" y="500%" du="1000" d="-3000" r="-30%" t3="L" x3="70%" du3="1600" src="images/full-width-slider/c-finger-pointing.png" style="position: absolute; width: 257px; height: 300px; top: 80px; left: 200px;" /> <img src="images/full-width-slider/c-navigator-horizontal.png" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" /> </div>
            <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;color: #FFFFFF;">Touch Swipe Slider </div>
            <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;text-align: left; line-height: 36px; font-size: 30px;color: #FFFFFF;"> Build your slider with anything, includes image, content, text, html, photo, picture </div>
          </div>
          <div> <img u="image" src="images/full-width-slider/purple.jpg" />
            <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;color: #FFFFFF;">Touch Swipe Slider </div>
            <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;text-align: left; line-height: 36px; font-size: 30px;color: #FFFFFF;"> Build your slider with anything, includes image, content, text, html, photo, picture </div>
          </div>
          <div> <img u="image" src="images/full-width-slider/blue.jpg" />
            <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;color: #FFFFFF;">Touch Swipe Slider </div>
            <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;text-align: left; line-height: 36px; font-size: 30px;color: #FFFFFF;"> Build your slider with anything, includes image, content, text, html, photo, picture </div>
          </div>
        </div>
    
        <!-- bullet navigator container -->
        <div u="navigator" class="jssorb21" style="bottom: 26px; right: 6px;">
          <!-- bullet navigator item prototype -->
          <div u="prototype"></div>
        </div>
    
        <!-- Arrow Left -->
        <span u="arrowleft" class="jssora21l" style="top: 123px; left: 8px;"> </span>
        <!-- Arrow Right -->
        <span u="arrowright" class="jssora21r" style="top: 123px; right: 8px;"> </span>
    
        <!-- / #slider1_container --></div>
      <div style="text-align:center; font-size: 1.5em; ">
        <p>full-width-slider</p>
        <p><a href="content-slider.html">content-slider</a>&nbsp;&nbsp;<a href="introduction-slider.html">introduction-slider</a>&nbsp;&nbsp;<a href="slider-cluster.html">slider-cluster</a></p>
      </div>
    

    サンプルのhtmlコード

    <!DOCTYPE html>
    <html lang="ja">
    <head>
    <meta charset="utf-8" />
    <title>jssor slider</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="css/full-width-slider.css" />
    </head>
    
    <body>
    <div class="container">
      <div id="slider1_container" style="position: relative; margin: 0 auto;
            top: 0px; left: 0px; width: 1300px; height: 500px; overflow: hidden;">
    
        <!-- Slides Container -->
        <div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 1300px;height: 500px; overflow: hidden;">
          <div> <img u="image" src="images/full-width-slider/red.jpg" />
            <div u="caption" t="NO" t3="RTT|2" r3="137.5%" du3="3000" d3="500" style="position: absolute; width: 445px; height: 300px; top: 100px; left: 600px;"> <img src="images/full-width-slider/c-phone.png" style="position: absolute; width: 445px; height: 300px; top: 0px; left: 0px;" /> <img u="caption" t="CLIP|LR" du="4000" t2="NO" src="images/full-width-slider/c-jssor-slider.png" style="position: absolute; width: 102px; height: 78px; top: 70px; left: 130px;" /> <img u="caption" t="ZMF|10" t2="NO" src="images/full-width-slider/c-text.png" style="position: absolute; width: 80px; height: 53px; top: 153px; left: 163px;" /> <img u="caption" t="RTT|10" t2="NO" src="images/full-width-slider/c-fruit.png" style="position: absolute; width: 140px; height: 90px; top: 60px; left: 220px;" /> <img u="caption" t="T" du="4000" t2="NO" src="images/full-width-slider/c-navigator.png" style="position: absolute; width: 200px; height: 155px; top: 57px; left: 121px;" /> </div>
            <div u="caption" t="RTT|2" r="-75%" du="1600" d="2500" t2="NO" style="position: absolute; width: 470px; height: 220px; top: 120px; left: 650px;"> <img src="images/full-width-slider/c-phone-horizontal.png" style="position: absolute; width: 470px; height: 220px; top: 0px; left: 0px;" /> <img u="caption" t3="MCLIP|L" du3="2000" src="images/full-width-slider/c-slide-1.jpg" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" /> <img u="caption" t="MCLIP|R" du="2000" t2="NO" src="images/full-width-slider/c-slide-3.jpg" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" /> <img u="caption" t="RTTL|BR" x="500%" y="500%" du="1000" d="-3000" r="-30%" t3="L" x3="70%" du3="1600" src="images/full-width-slider/c-finger-pointing.png" style="position: absolute; width: 257px; height: 300px; top: 80px; left: 200px;" /> <img src="images/full-width-slider/c-navigator-horizontal.png" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" /> </div>
            <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;color: #FFFFFF;">Touch Swipe Slider </div>
            <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;text-align: left; line-height: 36px; font-size: 30px;color: #FFFFFF;"> Build your slider with anything, includes image, content, text, html, photo, picture </div>
          </div>
          <div> <img u="image" src="images/full-width-slider/purple.jpg" />
            <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;color: #FFFFFF;">Touch Swipe Slider </div>
            <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;text-align: left; line-height: 36px; font-size: 30px;color: #FFFFFF;"> Build your slider with anything, includes image, content, text, html, photo, picture </div>
          </div>
          <div> <img u="image" src="images/full-width-slider/blue.jpg" />
            <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;color: #FFFFFF;">Touch Swipe Slider </div>
            <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;text-align: left; line-height: 36px; font-size: 30px;color: #FFFFFF;"> Build your slider with anything, includes image, content, text, html, photo, picture </div>
          </div>
        </div>
    
        <!-- bullet navigator container -->
        <div u="navigator" class="jssorb21" style="bottom: 26px; right: 6px;">
          <!-- bullet navigator item prototype -->
          <div u="prototype"></div>
        </div>
    
        <!-- Arrow Left -->
        <span u="arrowleft" class="jssora21l" style="top: 123px; left: 8px;"> </span>
        <!-- Arrow Right -->
        <span u="arrowright" class="jssora21r" style="top: 123px; right: 8px;"> </span>
    
        <!-- / #slider1_container --></div>
      <div style="text-align:center; font-size: 1.5em; ">
        <p>full-width-slider</p>
        <p><a href="content-slider.html">content-slider</a>&nbsp;&nbsp;<a href="introduction-slider.html">introduction-slider</a>&nbsp;&nbsp;<a href="slider-cluster.html">slider-cluster</a></p>
      </div>
    
      <!-- / .container --></div>
    
    <!--googleのCDN(ネットワーク経由でコンテンツを提供するサービス)よりjqueryをロード-->
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <!--ダウンロードしたファイル-->
    <script type="text/javascript" src="js/jssor.js"></script>
    <script type="text/javascript" src="js/jssor.slider.min.js"></script>
    <!--jsを外部化したファイル-->
    <script type="text/javascript" src="js/full-width-slider.js"></script>
    </body>
    </html>
    
  4. ファイル1式をサーバーにアップロードして設置完了。
    サンプル